package cn.tedu.spring2205.week02.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class TimeAspect {

    @Around("execution(* cn.tedu..aop.*.*(..))")
    public void getTime(ProceedingJoinPoint joinPoint) throws Throwable {
        //关注点代码
        long t1 = System.currentTimeMillis();
        //业务代码执行
        joinPoint.proceed();
        long t2 = System.currentTimeMillis();
        System.err.println(joinPoint.toShortString()+"耗时："+(t2-t1)+"毫秒");

    }
}
